<?php

namespace app\api\model;

use think\Model;

class User extends BaseModel
{

    public function address()
    {
        return $this->hasOne('UserAddress', 'user_id', 'id');
    }

    public static function getOneByOpendId($openid)
    {
        return self::where('openid', $openid)
                        ->find();
    }

    public static function CreateByOpendId($openid)
    {
        $user = self::create(
                        [
                            'openid' => $openid
        ]);
        return $user;
    }

}
